package com.yanqu.road.server.cmd.patrons;

import com.yanqu.road.pb.patrons.PatronsProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.patrons.PatronsModule;
import com.yanqu.road.server.pb.BasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Author wpj
 * @Date 2020/9/3
 */
@Cmd(code = GameProtocol.S_PATRONS_PUT_ON_SKIN, desc = "门客穿皮肤")
public class PatronsPutOnSkinCmd extends AbstractCommand {

    private int patronsId;
    private int skinId;
    private boolean isLinkageSwitch;            //联动切换

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PatronsProto.PatronsPutOnSkinReqMsg msg = PatronsProto.PatronsPutOnSkinReqMsg.parseFrom(packet.getBytes());
        patronsId = msg.getPatronsId();
        skinId = msg.getSkinId();
        isLinkageSwitch = msg.getIsLinkageSwitch();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(PatronsModule.class).putOnSkin(patronsId, skinId, isLinkageSwitch);
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(ClientProtocol.U_PATRONS_PUT_ON_SKIN, BasePb.getBaseRetRespMsg(ret));
    }
}
